#!/usr/bin/env python

import sys

if len(sys.argv) != 3:
    print "usage: gen_run_app.py NUM-CLIENTS NUM-MSG"
    sys.exit(0)

n = int(sys.argv[1])
nnodes = n + 2
runfile = open("run%d.app" % n, "w")
nmsg = int(sys.argv[2])
runfile.write("-np 1 ./bin/run_server %d 0\n" % nnodes)
runfile.write("-np 1 ./bin/run_client p %d 1 %d\n" % (nnodes, nmsg))
for i in xrange(n):
    idx = i + 2
    runfile.write("-np 1 ./bin/run_client c %d %d %d\n" %  (nnodes, idx, nmsg))

print runfile.name
